package com.video.controller;

import com.video.form.LoginForm;
import com.video.result.ResultVO;
import com.video.service.UsersService;
import com.video.vo.RegisterVo;
import com.video.vo.UpdateUserInfoVo;
import com.video.vo.UpdateUserTagVo;
import com.video.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.simpleframework.xml.Path;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author baoshuai
 * @date 2022/12/14
 */
@RestController
@Api(value = "提供用户的登录和注册接口", tags = "用户接口模块")
@RequestMapping("/user")
public class UserController {

    @Resource
    private UsersService usersService;

    @ApiOperation("查询用户信息")
    @GetMapping("/{userId}")
    public ResultVO getUserInfo(@PathVariable Long userId) {
        return usersService.getUserInfo(userId);
    }

    @ApiOperation("修改用户信息")
    @PutMapping("/modify")
    public ResultVO modifyUserInfo(@RequestBody UpdateUserInfoVo updateUserInfoVo) {
        return usersService.modifyUserInfo(updateUserInfoVo);
    }

    @ApiOperation("用户注册")
    @PostMapping("/register")
    public ResultVO register(@RequestBody RegisterVo registerVo) {
        return usersService.register(registerVo);
    }

    @ApiOperation("用户登陆")
    @PostMapping("/login")
    public ResultVO login(@RequestBody LoginForm loginForm) {
        return usersService.login(loginForm);
    }

    @ApiOperation("获取用户标签")
    @GetMapping("/getUserTag/{userId}")
    public ResultVO getUserTag(@PathVariable Long userId) {
        return usersService.getUserTag(userId);
    }

    @ApiOperation("修改用户标签")
    @PutMapping("/modifyUserTag")
    public ResultVO modifyUserTag(@RequestBody UpdateUserTagVo updateUserTagVo) {
        return usersService.modifyUserTag(updateUserTagVo);
    }

}